import React, { useState } from 'react';
import { NavBar, List, InputItem, Picker, Icon, Button, ImagePicker } from 'antd-mobile';
import { district, provinceLite } from 'antd-mobile-demo-data';

import { sexList } from "@/assets/js/dict.js"

import { createForm } from 'rc-form';

import './signUpTutor.scss';


const Item = List.Item;
const Brief = Item.Brief;

function BiographicalNotes(props) {
    const [SignUpTutor, SetSignUpTutor] = useState({
        file: []
    })
    const [hasError, SetHasError] = useState(false);


    // 简历
    function handleLogin() {
        let postData = {};
        postData = props.form.getFieldsValue()

        console.log('props.form ------>>>', props.form)
        console.log('SignUpTutor ----->>>>', postData.SignUpTutor)

        // 跳转login
        // props.history.push('/login')
    };

    let onChange = (files, type, index) => {
        console.log(files, type, index);
        // this.setState({
        //   files,
        // });
    }
    let onSegChange = (e) => {
        const index = e.nativeEvent.selectedSegmentIndex;
        this.setState({
            multiple: index === 1,
        });
    }

    const { getFieldProps } = props.form;

    return (
        <div className="SignUp">
            <div className="page-title">
                <NavBar
                    mode="light"
                    icon={<Icon type="left" />}
                    onLeftClick={() => {
                        props.history.goBack()
                    }}
                >
                    注册
                </NavBar>
            </div>
            <div className="page-content">
                <List>
                    <InputItem
                        {...getFieldProps('SignUpTutor.name')}
                        clear
                        placeholder="请输入姓名"
                    >姓名</InputItem>

                    <Picker
                        data={sexList}
                        cols={1}
                        {...getFieldProps('SignUpTutor.sex')}

                    >
                        <List.Item arrow="horizontal">性別</List.Item>
                    </Picker>

                    <InputItem
                        {...getFieldProps('SignUpTutor.phone')}
                        placeholder="请输入手机号码"
                        clear
                    >手机号码</InputItem>

                    <InputItem
                        {...getFieldProps('SignUpTutor.address')}
                        clear
                        placeholder="学校/学院"
                    >学校/学院</InputItem>
                    <InputItem
                        {...getFieldProps('SignUpTutor.address')}
                        clear
                        placeholder="学校/学院"
                    >学号</InputItem>
                    <Item multipleLine onClick={() => { }}>
                        学生证照片
                        <Brief>
                            <ImagePicker
                                // files={'SignUpTutor.file'}
                                {...getFieldProps('SignUpTutor.file')}
                                onChange={onChange}
                                onImageClick={(index, fs) => console.log(index, fs)}
                                selectable={SignUpTutor.file.length < 7}
                                multiple={true}
                            />
                        </Brief>
                    </Item>
                    <InputItem
                        {...getFieldProps('SignUpTutor.address')}
                        clear
                        placeholder="邮箱"
                    >邮箱</InputItem>
                    <InputItem
                        {...getFieldProps('SignUpTutor.password')}
                        clear
                        placeholder="请输入密码"
                    >密码</InputItem>
                    <InputItem
                        {...getFieldProps('SignUpTutor.repassword')}
                        clear
                        placeholder="请确认密码"
                    >确认密码</InputItem>

                </List>
            </div>
            <Button type="primary" onClick={() => { handleLogin() }}>注册</Button>
        </div>
    );
}

BiographicalNotes = createForm()(BiographicalNotes);

export default BiographicalNotes;